<?php
// data/init.php
// 创建到服务器的连接，连接数据库  mysqli_connect(IP, 用户名，密码，数据库名)  连接数据库  
$link = @mysqli_connect('127.0.0.1', 'root', '', 'test');
// 准备sql语句
$name = $_POST['user'];
$pwd = $_POST['pwd'];
$sql = "select * from login where name='$name' and pwd='$pwd'";
// 执行sql语句
$res = mysqli_query($link, $sql);
//  echo mysqli_fetch_assoc($res);
if (mysqli_num_rows($res) > 0) {
  // $str = mysqli_fetch_assoc($res);
  // print_r($str);
  echo json_encode(array(
    "code" => 200,
    // "data" => $str,
    "msg" => "登录成功"
  ));
} else {
  echo json_encode(array(
    "code" => 500,
    // "data" => '',
    "msg" => "手机号或密码错误"
  ));
}
